package main

import (
	"os"
	"os/signal"
	"syscall"

	"hermestrans/internal/portal/service"

	"github.com/sirupsen/logrus"
	_ "go.uber.org/automaxprocs"
)

func signalExit() chan int {
	exitChan := make(chan int)
	signalChan := make(chan os.Signal, 1)
	go func() {
		<-signalChan
		logrus.Info("exit signal received")
		service.Stop()
		exitChan <- 1
	}()
	signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
	return exitChan
}

func main() {
	service.Start()
	<-signalExit()
}
